var menu = [

//These need to be modified so that it scrolls to the proper place on the page,
//querry.php may need to be modified slightly to do this.
	{"name": "Clients", "href": "?page=clients", "submenu": [
		{"name":"File System", "href": "?page=clients"},
		{"name":"Client Access", "href": "?page=clients"}
	]},
	{"name": "Contact", "href": "?page=contact", "submenu": [
		{"name":"css", "href": "?page=contact"},
		{"name":"Telephone", "href": "?page=contact"},
		{"name":"Postal", "href": "?page=contact"},
		{"name":"Map", "href": "?page=contact"}
	]},
	{"name": "Portfolio", "href": "?page=portfolio", "submenu": [
		{"name":"Desktop Application", "href": "?page=portfolio"},
		{"name":"Web Development", "href": "?page=portfolio"},
		{"name":"PDA Applications", "href": "?page=portfolio"},
	]},
	{"name": "Profile", "href": "?page=profile", "submenu": [
		{"name":"History", "href": "?page=profile"}		
	]},	
	{"name": "Services", "href": "?page=services", "submenu": [
		{"name":"Desktop Application", "href": "?page=services"},
		{"name":"PDA Applications", "href": "?page=services"},
		{"name":"Web Developement", "href": "?page=services"},
		{"name":"Graphic Design", "href": "?page=services"},
		{"name":"Web Hosting", "href": "?page=services"}
	]},		
	{"name": "Web Hosting", "href": "?section=webhosting&page=webhosting", "submenu": [
		{"name":"Host Accounts", "href": "?section=webhosting&page=webhosting"},
		{"name":"Services", "href": "?section=webhosting&page=webservice"},
		{"name":"References", "href": "?section=webhosting&page=webref"},
		{"name":"How-to", "href": "?section=webhosting&page=webhow-to"}
	]},
	{"name": "Admin", "href": "?section=admin&page=AccountManTools", "submenu": [
		{"name":"Tools", "href": "?section=admin&page=AccountManTools"},
		{"name":"Wiki", "href": "?section=admin&page=wiki"},
		{"name":"Speak Easy", "href": "?section=admin&page=speakEasy"},
		{"name":"Mail", "href": "?section=admin&page=Mail"},
		{"name":"System Information", "href": "?section=admin&page=SystemInfo"},
		{"name":"Misc", "href": "?section=admin&page=Misc"},
		{"name":"Contact Information", "href": "?section=admin&page=ContactInfo"},
	]}	
	
]

window.onload = function() {


	var sidebar = document.createElement("div");
	sidebar.id = "Sidebar";
	document.body.appendChild(sidebar);



	var ul = document.createElement("ul");
	ul.id = "ul2"

	// MENU GENERATION CODE HERE

	for (var i = 0; i < menu.length; ++i) {
		var li = document.createElement("li");
		
		/***************************************/
		/***************************************/
		/**    when commented out the code *****/
		/************   works   ****************/
		/***************************************/
		/***************************************/
		
		
		
	        //li.setAttribute('class',"SideLink");
	    var newAttr = document.createAttribute("class");
		newAttr.nodeValue = "SideLink";
		li.setAttributeNode(newAttr);
	        
	        
		/***************************************/
		/***************************************/	        
	        

		var a = document.createElement("a");
		var t = document.createTextNode(menu[i].name)
		a.href = menu[i].href;
		a.name = menu[i].name;
		
		a.onclick = function() { window.name = this.name }
		a.appendChild(t);
		li.appendChild(a);

		// SUBMENU GOES HERE
		if (menu[i].submenu && window.name == menu[i].name) {
			var ul2 = document.createElement('ul');
			// ul2.setAttribute("class","SubLink");
			
			var submenu = menu[i].submenu;
			for (var j = 0; j < submenu.length; ++j) {
			
					var li2 = document.createElement("li");
					/***************************************/
					/***************************************/
					/**    when commented out the code *****/
					/************   works   ****************/
					/***************************************/
					/***************************************/
					
					
					// li2.setAttribute('class',"SubLink");
					var newAttr = document.createAttribute("class");
					newAttr.nodeValue = "SubLink";
					li2.setAttributeNode(newAttr);
					
					/***************************************/
					/***************************************/					
					//adding the a tag
					var a2 = document.createElement("a");
					
					// adding the image tag
					var img3 = document.createElement("img");
					img3.setAttribute('src',"images/nav/sub_link.gif");
					img3.setAttribute('class',"sublinkimage");
					a2.appendChild(img3);
					
					
					var t2 = document.createTextNode(submenu[j].name)
					a2.href = submenu[j].href;
					a2.appendChild(t2);
					
					
					
					
			
					li2.appendChild(a2);
					ul2.appendChild(li2);
			}
			var libr = document.createElement("li");
			var br = document.createElement("br");
			libr.appendChild(br);
			var AttrSub = document.createAttribute("class");
			AttrSub.nodeValue = "SubLink";
			libr.setAttributeNode(AttrSub);
			ul2.appendChild(libr);
			
			li.appendChild(ul2);
		}
		
		ul.appendChild(li);
	}


	// ENDS HERE

	sidebar.appendChild(ul);
	

	// ----



}


